package TEST;

public class TestPSO {

	static double fit(double x){
		return Absolute(8000.0 + x*(-10000.0 + x*(-0.8 + x)));
	}

	private static double Absolute(double d) {
		if(d < 0)
			  d = d * -1;
		return d;
	}

	public static void main(String[] args)
	{
	    double low = -100.0, up = 100.0, step = 0.0001;
	    double x, max = (low), max_x = low;
	    for(x = low + step; x <= up; x += step)
	        if(fit(x) > max){
	            max_x = x; 
	            max = fit(x);
	        }
	    System.out.printf("Max : \n" + "x = " + max_x + "\nf(x) = " + max);
	}

}
